package com.tanhua.server.controller;


import com.tanhua.domain.vo.SoulQuestionListVo;
import com.tanhua.server.interceptor.UserHolder;
import com.tanhua.server.service.SoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 测灵魂功能
 */
@RestController
@RequestMapping("/testSoul")
public class SoulController {
    @Autowired
    private SoulService soulService;
    
    
    /**
     * 接口名称：测灵魂-问卷列表
     * 接口路径：GET /testSoul
     */
    @GetMapping
    public ResponseEntity<Object> soulQuestionList() {
        Long userId = UserHolder.getUserId();
        List<SoulQuestionListVo> soulQuestionList = soulService.soulQuestionList(userId);
        return ResponseEntity.ok(soulQuestionList);
    }
    
    
    /**
     * 接口名称：测灵魂-提交问卷
     * 接口路径：POST /testSoul
     */
    @PostMapping
    public ResponseEntity<Object> submitAnswer(@RequestBody String answers) {
        Long userId = UserHolder.getUserId();
        return soulService.submitAnswer(userId, answers);
    }
    
    
    /**
     * 接口名称：测灵魂-查看结果
     * 接口路径：GET /testSoul/report/:id
     */
    @GetMapping("/report/{id}")
    public ResponseEntity<Object> viewReport(@PathVariable("id") String id) {
        Long userId = UserHolder.getUserId();
        return soulService.viewReport(userId, Long.valueOf(id));
    }
    
}
